<template>
	<div class="special_assignments_div" v-loading="tableLoading" element-loading-text="数据加载中">
		<div class="special_assignments_query_div">
			<el-form :model="searchForm" :inline="true" size="small">
				<el-form-item label="" label-width="0">
					<el-input v-model="searchForm.work_code" placeholder="请输入编号" clearable
						@clear="currentPage = 1; inquiry()"></el-input>
				</el-form-item>
				<el-form-item label="" label-width="0" >
					<el-select v-model="searchForm.state" @change="currentPage = 1; inquiry()" clearable placeholder="请选择状态" @clear="currentPage = 1; inquiry()">
						<el-option
						v-for="(option, index) in stateOptions"
						:key="index"
						:label="option.label"
						:value="option.value"
						/>
					</el-select>
				</el-form-item>
				<el-form-item label="" label-width="0" >
					<!-- <el-select v-model="searchForm.state" @change="currentPage = 1; inquiry()" clearable placeholder="请选择申请单位" @clear="currentPage = 1; inquiry()">
						<el-option
						v-for="(option, index) in stateOptions"
						:key="index"
						:label="option.label"
						:value="option.value"
						/>
					</el-select> -->

				<el-select
					ref="singleTree"
					v-model="searchForm.apply_com"
					class="vab-tree-select"
					clearable
					placeholder="请选择申请单位"
					popper-class="select-tree-popper"
					value-key="id"
					@clear="selectTreeClearHandle()"
					>
					<el-option :value="searchForm.apply_com">
						<el-tree
						id="singleSelectTree"
						ref="singleSelectTree"
						:current-node-key="searchForm.apply_com"
						:data="selectTreeData"
						:default-expanded-keys="selectTreeDefaultSelectedKeys"
						:highlight-current="true"
						node-key="id"
						:props="selectTreeDefaultProps"
						@node-click="selectTreeNodeClick"
						>
						<template #defalut="{ node }">
							<span class="vab-tree-item">{{ node.label }}</span>
						</template>
						</el-tree>
					</el-option>
				</el-select>


				</el-form-item>
				<el-form-item label="" label-width="0">
					<el-date-picker
						@change="currentPage = 1; inquiry()"
						@clear="currentPage = 1; inquiry()"
						v-model="searchForm.dateRange"
						type="datetimerange"
						range-separator="至"
						start-placeholder="请选择作业申请时间"
						end-placeholder="请选择作业申请时间"
						format="yyyy-MM-dd HH:mm:ss"
						value-format="yyyy-MM-dd HH:mm:ss"
						:clearable="true"
						/>
					<!-- <el-input v-model="searchForm.msginfo" placeholder="请输入编号" clearable
						@clear="currentPage = 1; inquiry()"></el-input> -->
				</el-form-item>
				
				<el-form-item>
					<el-button type="primary" icon="el-icon-search" @click="currentPage = 1; inquiry()">搜索</el-button>
					<el-button type="success" icon="el-icon-circle-plus-outline" @click="addClick()">添加</el-button>
				</el-form-item>
			</el-form>
		</div>
		<div class="special_assignments_table_div">
			<el-table :data="tableData" style="width: 100%" height="100%">
				<el-table-column label="编号" align="center" show-overflow-tooltip width="200"
					prop="work_code"></el-table-column>
				<el-table-column label="作业票模板" align="center" show-overflow-tooltip width="120"
					prop="mbname"></el-table-column>
				<el-table-column label="申请人" align="center" width="100" prop="createpeople"></el-table-column>
				<el-table-column label="作业申请单位" align="center" width="110" show-overflow-tooltip
					prop="apply_com"></el-table-column>
				<el-table-column label="作业申请时间" align="center" width="160" show-overflow-tooltip
					prop="createtime"></el-table-column>
				<!-- <el-table-column label="作业等级" align="center" show-overflow-tooltip width="150" prop="level"></el-table-column> -->
				
				<el-table-column label="作业开始时间" align="center" width="160" show-overflow-tooltip
					prop="startTime"></el-table-column>
				<el-table-column label="作业结束时间" align="center" width="160" show-overflow-tooltip
					prop="endTime"></el-table-column>
				<el-table-column label="操作" width="400" fixed="right" align="center">
					<template slot-scope="scope">

						<CustomButton :onClick="() => handlelook(scope.row)">详情</CustomButton>

						<CustomButton :onClick="() => processClick(scope.row)">全流程监控</CustomButton>

						<CustomButton  :onClick="() => exportClick(scope.row, '2')" >预览
										<!-- {{  scope.row.state == '12' ? '导出' : '预览' }} -->
						</CustomButton>

						<el-dropdown style="margin-left: 15px;" placement="bottom" v-if="scope.row.state * 1 !== 12">
							<span class="el-dropdown-link">
								<CustomButton>更多</CustomButton>
								<i class="el-icon-arrow-down el-icon--right"></i>
							</span>
							<el-dropdown-menu slot="dropdown">

				

								<el-dropdown-item>
									<CustomButton color="#ff6666" :onClick="() => delClick(scope.row, '2')"  width="100%"
										v-if="permission.canDelete(scope.row)">删除</CustomButton>
								</el-dropdown-item>

							</el-dropdown-menu>
						</el-dropdown>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<div class="special_assignments_footer_div" v-show="pageLength * 1 > 0">
			<el-pagination @size-change="handleSizeChange" background @current-change="handleCurrentChange"
				:current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize"
				layout="total, sizes, prev, pager, next, jumper" :total="pageLength">
			</el-pagination>
		</div>

		<el-dialog title="添加信息" top="2vh" :visible.sync="dialogFormVisibleAdd" width="60%" :before-close="handleClose">
			<addView ref="addView" :key="addViewTime"></addView>
			<span slot="footer" class="dialog-footer">
				<!-- <el-button type="warning" @click="COPY_COPY_1()">赋值基础信息</el-button>
				<el-button type="warning" @click="COPY_COPY_2()">赋值人员信息</el-button>
				<el-button type="warning" @click="COPY_COPY_3()">赋值部门</el-button>
				<el-button type="warning" @click="COPY_COPY_4()">赋值安全措施</el-button> -->
				<el-button @click="dialogFormVisibleAdd = false">取 消</el-button>
				<el-button type="primary" @click="confirmAdd" :disabled="!buttonCartoon">
					{{ buttonCartoon ? '确 定' : '添加中...' }}
				</el-button>
			</span>
		</el-dialog>


		<el-dialog title="编辑信息" top="2vh" :visible.sync="dialogFormVisibleEdit" width="60%">
			<editView ref="editRef" :key="editViewTime"></editView>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogFormVisibleEdit = false">取 消</el-button>
				<el-button type="primary" @click="confirmEdit">确 定</el-button>
			</span>
		</el-dialog>

		<!-- 风险辨识确认 -->
		<el-dialog title="风险辨识确认" top="5vh" :visible.sync="dialogVisibleRiskConfirm" width="50%">
			<riskConfirm ref="riskConfirmRef" />
		</el-dialog>

		<!-- 措施确认 -->
		<el-dialog title="措施确认" :visible.sync="dialogVisibleCsConfirm" width="70%" :before-close="handleClose">
			<csConfirm ref="csConfirmRef" />
		</el-dialog>

		<!-- 接收交底 -->
		<el-dialog title="接收交底" :visible.sync="dialogVisibleSecureJdr" width="50%">
			<secureJDR ref="secureJDRRefs"></secureJDR>
		</el-dialog>

		<!-- 气体分析人 -->
		<el-dialog title="气体分析" :visible.sync="dialogFormVisibleQtFx" width="70%" :before-close="handleClose">
			<qtFx ref="qtFxRefs" />
		</el-dialog>

		<!-- 审核人 -->
		<el-dialog title="审核人选择" :visible.sync="dialogFormVisibleReviewer" width="70%">
			<reviewer ref="reviewerRefs" />
		</el-dialog>

		<!-- 监护人意见 -->
		<el-dialog title="监护人意见" :visible.sync="dialogFormVisibleGuardianOpinion" width="50%">
			<guardianOpinion ref="guardianOpinionRefs" />
		</el-dialog>

		<!-- 单位验收 通用组件-->
		<acceptance ref="acceptanceRefs" />

		<!-- 交接班 通用组件-->
		<assignedPerson ref="assignedPersonRefs" />

		<!-- 详情组件-->
		<detailsView ref="detailsViewRefs" ></detailsView>

		<!-- 全流程监控 -->
		<fullProcess ref="fullProcessRefs"></fullProcess>

		<!-- 接受交底 通用组件 -->
		<acceptDisclosure ref="acceptDisclosureRefs"/>

		<iframe-dialog ref="iframeDialog" :iframeUrl="iframeUrl" :dialog-title="dialogTitle"/>

	</div>
</template>